package cn.ffcs.uec.staff.model;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import cn.ffcs.uec.common.vo.UecBdDefdoc;
import cn.ffcs.uec.common.vo.UecBdPsncl;
import cn.ffcs.uec.organization.model.UecOrgDept;
import cn.ffcs.uec.organization.model.UecOrgOrgs;
import cn.ffcs.uec.post.model.UecPost;
import cn.ffcs.uec.staff.dao.UecPsnjobDao;
import cn.ffcs.uom.common.constants.BaseUnitConstants;
import cn.ffcs.uom.common.model.UomEntity;
import cn.ffcs.uom.common.util.ApplicationContextUtil;
import cn.ffcs.uom.common.util.StrUtil;
import lombok.Getter;
import lombok.Setter;

/**
 * @Title:任职信息实体
 * @Description:
 * @Copyright: FFCS（C） 2017
 * @Company: FFCS
 * @author Wang Yiren
 * @Version 0.0.1 date:2017年12月14日
 * @since JDK1.6
 */
public class UecPsnjob extends UomEntity implements Serializable, Cloneable {

	private static final long serialVersionUID = -3143904497218106997L;

	/**
	 * 任职信息标识
	 * 
	 * @return
	 */
	public Long getPsnjobId() {
		return super.getId();
	}

	public void setPsnjobId(Long psnjobId) {
		super.setId(psnjobId);
	}

	/**
	 * 员工标识
	 */
	@Getter
	@Setter
	private Long staffId;
	/**
	 * 员工类型 =1：合同制、派遣制 =2：外包自有、其他
	 */
	@Getter
	@Setter
	private String nmStaffType;
	/**
	 * 账期
	 */
	@Getter
	@Setter
	private Long monthId;
	/**
	 * 人员任职ID
	 */
	@Getter
	@Setter
	private Long assgid;
	/**
	 * 开始日期
	 */
	@Getter
	@Setter
	private String begindate;
	/**
	 * 员工号
	 */
	@Getter
	@Setter
	private String clerkcode;
	/**
	 * 创建时间
	 */
	@Getter
	@Setter
	private String creationtime;
	/**
	 * 创建人
	 */
	@Getter
	@Setter
	private String creator;
	/**
	 * 免职方式
	 */
	@Getter
	@Setter
	private String deposemode;
	/**
	 * 删除标示
	 */
	@Getter
	@Setter
	private Long dr;
	/**
	 * 结束日期
	 */
	@Getter
	@Setter
	private String enddate;
	/**
	 * 是否结束
	 */
	@Getter
	@Setter
	private String endflag;
	/**
	 * 是否主职
	 */
	@Getter
	@Setter
	private String ismainjob;
	/**
	 * 人员状态
	 */
	@Getter
	@Setter
	private String jobglbdef1;
	/**
	 * 进入本单位来源--jobglbdef10
	 */
	@Getter
	@Setter
	private String jobglbdef10;
	/**
	 * 岗位层级1
	 */
	@Getter
	@Setter
	private String jobglbdef2;
	/**
	 * 岗位等级1
	 */
	@Getter
	@Setter
	private String jobglbdef3;
	/**
	 * 职务名称
	 */
	@Getter
	@Setter
	private String jobglbdef4;
	/**
	 * 任职原因
	 */
	@Getter
	@Setter
	private String jobglbdef5;
	/**
	 * 任职文号
	 */
	@Getter
	@Setter
	private String jobglbdef6;
	/**
	 * 免职文号
	 */
	@Getter
	@Setter
	private String jobglbdef7;
	/**
	 * 任现岗级时间
	 */
	@Getter
	@Setter
	private String jobglbdef8;
	/**
	 * 岗位工资档次
	 */
	@Getter
	@Setter
	private String jobglbdef9;
	/**
	 * 任职方式
	 */
	@Getter
	@Setter
	private String jobmode;
	/**
	 * 最新记录
	 */
	@Getter
	@Setter
	private String lastflag;
	/**
	 * 修改时间
	 */
	@Getter
	@Setter
	private String modifiedtime;
	/**
	 * 修改人
	 */
	@Getter
	@Setter
	private String modifier;
	/**
	 * 部门
	 */
	@Getter
	@Setter
	private String pkDept;
	/**
	 * 人力资源组织
	 */
	@Getter
	@Setter
	private String pkHrorg;
	/**
	 * 组织
	 */
	@Getter
	@Setter
	private String pkOrg;
	/**
	 * 岗位
	 */
	@Getter
	@Setter
	private String pkPost;
	/**
	 * 外包员工岗位
	 */
	@Getter
	@Setter
	private String outJobName;
	/**
	 * 岗位序列
	 */
	@Getter
	@Setter
	private String pkPostseries;
	/**
	 * 人员类别
	 */
	@Getter
	@Setter
	private String pkPsncl;
	/**
	 * 人员基本信息
	 */
	@Getter
	@Setter
	private String pkPsndoc;
	/**
	 * 主键
	 */
	@Getter
	@Setter
	private String pkPsnjob;
	/**
	 * 组织关系
	 */
	@Getter
	@Setter
	private String pkPsnorg;
	/**
	 * 在岗
	 */
	@Getter
	@Setter
	private String poststat;
	/**
	 * 人员类型
	 */
	@Getter
	@Setter
	private Long psntype;
	/**
	 * 试用
	 */
	@Getter
	@Setter
	private String trialFlag;
	/**
	 * 试用类型
	 */
	@Getter
	@Setter
	private Long trialType;
	/**
	 * 异动业务
	 */
	@Getter
	@Setter
	private Long trnsevent;
	/**
	 * 异动原因
	 */
	@Getter
	@Setter
	private String trnsreason;
	/**
	 * 异动类型
	 */
	@Getter
	@Setter
	private String trnstype;
	/**
	 * 时间戳
	 */
	@Getter
	@Setter
	private String ts;
	/**
	 * 人员状态
	 */
	@Getter
	@Setter
	private String glbdef1;
	/**
	 * 任职原因
	 */
	@Getter
	@Setter
	private String glbdef5;
	/**
	 * 任职文号
	 */
	@Getter
	@Setter
	private String glbdef6;//N
	/**
	 * 免职文号
	 */
	@Getter
	@Setter
	private String glbdef7;//N
	/**
	 * 任现岗级时间
	 */
	@Getter
	@Setter
	private String glbdef8;
	/**
	 * 部门层级关系
	 */
	@Getter
	@Setter
	private String jobglbdef12;
	/**
	 * 人员类别备注
	 */
	@Getter
	@Setter
	private String jobglbdef13;
	/**
	 * 现职时间
	 */
	@Getter
	@Setter
	private String jobglbdef14;
	/**
	 * 任职时间
	 */
	@Getter
	@Setter
	private String jobglbdef15;
	/**
	 * 本级时间
	 */
	@Getter
	@Setter
	private String jobglbdef16;
	/**
	 * oa账号
	 */
	@Getter
	@Setter
	private String oaUid;

	/**
	 * 任职类型--pkJobType
	 */
	@Getter
	@Setter
	private String pkJobType;

	/**
	 * 是否小CEO
	 */
	@Getter
	@Setter
	private String jobglbdef21;

	@Getter
	@Setter
	private String jobglbdef22;

	@Getter
	@Setter
	private String jobglbdef23;

	@Getter
	@Setter
	private String jobglbdef24;

	@Getter
	@Setter
	private String jobglbdef25;

	@Getter
	@Setter
	private String jobglbdef26;
	
	//服务于外包自助里，任职信息
	@Getter
	@Setter
	private String psnCode;
	@Getter
	@Setter
	private String psnName;

	/**
	 * 创建对象实体
	 */
	public static UecPsnjob newInstance() {
		return new UecPsnjob();
	}

	@Override
	public Object clone() {
		UecPsnjob psnjob = null;
		try {
			psnjob = (UecPsnjob) super.clone();
		} catch (CloneNotSupportedException e) {
			e.printStackTrace();
		}
		return psnjob;
	}

	/**
	 * 获取dao
	 */
	public UecPsnjobDao repository() {
		return (UecPsnjobDao) ApplicationContextUtil.getBean("uecPsnjobDao");
	}
	/**
	 * 获取岗位等级--jobglbdef3
	 */
	public String getJobglbdef3Name() {
		if (!StrUtil.isNullOrEmpty(this.getJobglbdef3())) {
			String sql = " SELECT * FROM  UEC_BD_DEFDOC T WHERE T.PK_DEFDOC = ? ";
			List<Object> params = new ArrayList<Object>();
			params.add(this.getJobglbdef3());
			List<UecBdDefdoc> list = this.repository().jdbcFindList(sql, params, UecBdDefdoc.class);
			if (list != null && list.size() > 0) {
				return list.get(0).getName();
			}
		}
		return "";
	}
	/**
	 * 获取组织--pkHrorg
	 */
	public String getPkHrorgName() {
		if (!StrUtil.isNullOrEmpty(this.getPkHrorg())) {
			String sql = " SELECT * FROM  UEC_ORG_ORGS T WHERE T.STATUS_CD = ? AND T.PK_ORG = ? ";
			List<Object> params = new ArrayList<Object>();
			params.add(BaseUnitConstants.ENTT_STATE_ACTIVE);
			params.add(this.getPkHrorg());
			List<UecOrgOrgs> list = this.repository().jdbcFindList(sql, params, UecOrgOrgs.class);
			if (list != null && list.size() > 0) {
				return list.get(0).getName();
			}
		}
		return "";
	}
	/**
	 * 获取组织--pkorg
	 */
	public String getPkorgName() {
		if (!StrUtil.isNullOrEmpty(this.getPkOrg())) {
			String sql = " SELECT * FROM  UEC_ORG_ORGS T WHERE T.STATUS_CD = ? AND T.PK_ORG = ? ";
			List<Object> params = new ArrayList<Object>();
			params.add(BaseUnitConstants.ENTT_STATE_ACTIVE);
			params.add(this.getPkOrg());
			List<UecOrgOrgs> list = this.repository().jdbcFindList(sql, params, UecOrgOrgs.class);
			if (list != null && list.size() > 0) {
				return list.get(0).getName();
			}
		}
		return "";
	}

	/**
	 * 获取部门
	 */
	public String getPkDeptName() {
		if (!StrUtil.isNullOrEmpty(this.getPkDept())) {
			String sql = " SELECT * FROM  UEC_ORG_DEPT T WHERE T.STATUS_CD = ? AND T.PK_DEPT = ? ";
			List<Object> params = new ArrayList<Object>();
			params.add(BaseUnitConstants.ENTT_STATE_ACTIVE);
			params.add(this.getPkDept());
			List<UecOrgDept> list = this.repository().jdbcFindList(sql, params, UecOrgDept.class);
			if (list != null && list.size() > 0) {
				return list.get(0).getName();
			}
		}
		return "";
	}
	/**
	 * 获取岗位-pkPost
	 */
	public String getPkPostName() {
		if (!StrUtil.isNullOrEmpty(this.getPkPost())) {
			String sql = " SELECT * FROM  UEC_POST T WHERE T.STATUS_CD = ? AND T.PK_POST = ? ";
			List<Object> params = new ArrayList<Object>();
			params.add(BaseUnitConstants.ENTT_STATE_ACTIVE);
			params.add(this.getPkPost());
			List<UecPost> list = this.repository().jdbcFindList(sql, params, UecPost.class);
			if (list != null && list.size() > 0) {
				return list.get(0).getPostname();
			}
		}
		return "";
	}
	
	/**
	 * 获取人员类型--psntype
	 */
	public String getPsntypeName() {
		if(null != this.getPsntype()) {
			if(0L == this.getPsntype()) {
				return "新进";
			}else if(1L == this.getPsntype()) {
				return "变更";
			}else if(2L == this.getPsntype()) {
				return "退出";
			}
		}
		return "";
	}
	
	/**
	 * 是否主职--ismainjob
	 */
	public String getIsmainjobName() {
		if(!StrUtil.isEmpty(this.getIsmainjob())) {
			if("Y".equals(this.getIsmainjob())) {
				return "是";
			}else if("N".equals(this.getIsmainjob())) {
				return "否";
			}
		}
		return "";
	}
	
	/**
	 * 获取人员类别--pkPsncl
	 */
	public String getPkPsnclName() {
		if (!StrUtil.isNullOrEmpty(this.getPkPsncl())) {
			String sql = " SELECT * FROM  UEC_BD_PSNCL T WHERE  T.PK_PSNCL = ? ";
			List<Object> params = new ArrayList<Object>();
			params.add(this.getPkPsncl());
			List<UecBdPsncl> list = this.repository().jdbcFindList(sql, params, UecBdPsncl.class);
			if (list != null && list.size() > 0) {
				return list.get(0).getName();
			}
		}
		return "";
	}
	
	/**
	 * 进入本单位来源--jobglbdef10
	 */
	public String getJobglbdef10Name() {
		if (!StrUtil.isNullOrEmpty(this.getJobglbdef10())) {
			String sql = " SELECT * FROM  UEC_BD_DEFDOC T WHERE T.PK_DEFDOC = ? ";
			List<Object> params = new ArrayList<Object>();
			params.add(this.getJobglbdef10());
			List<UecBdDefdoc> list = this.repository().jdbcFindList(sql, params, UecBdDefdoc.class);
			if (list != null && list.size() > 0) {
				return list.get(0).getName();
			}
		}
		return "";
	}
	/**
	 * 岗位层级--jobglbdef2
	 */
	public String getJobglbdef2Name() {
		if (!StrUtil.isNullOrEmpty(this.getJobglbdef2())) {
			String sql = " SELECT * FROM  UEC_BD_DEFDOC T WHERE T.PK_DEFDOC = ? ";
			List<Object> params = new ArrayList<Object>();
			params.add(this.getJobglbdef2());
			List<UecBdDefdoc> list = this.repository().jdbcFindList(sql, params, UecBdDefdoc.class);
			if (list != null && list.size() > 0) {
				return list.get(0).getName();
			}
		}
		return "";
	}
	
	/**
	 * 任职类型--pkJobType
	 */
	public String getPkJobTypeName() {
		if (!StrUtil.isNullOrEmpty(this.getPkJobType())) {
			String sql = " SELECT * FROM  UEC_BD_DEFDOC T WHERE T.PK_DEFDOC = ? ";
			List<Object> params = new ArrayList<Object>();
			params.add(this.getPkJobType());
			List<UecBdDefdoc> list = this.repository().jdbcFindList(sql, params, UecBdDefdoc.class);
			if (list != null && list.size() > 0) {
				return list.get(0).getName();
			}
		}
		return "";
	}
	/**
	 * 一级基准岗位--jobglbdef22
	 */
	public String getJobglbdef22Name() {
		if (!StrUtil.isNullOrEmpty(this.getJobglbdef22())) {
			String sql = " SELECT * FROM  UEC_POST T WHERE T.STATUS_CD = ? AND T.PK_POST = ? ";
			List<Object> params = new ArrayList<Object>();
			params.add(BaseUnitConstants.ENTT_STATE_ACTIVE);
			params.add(this.getJobglbdef22());
			List<UecPost> list = this.repository().jdbcFindList(sql, params, UecPost.class);
			if (list != null && list.size() > 0) {
				return list.get(0).getPostname();
			}
		}
		return "";
	}
	/**
	 * 二级基准岗位--jobglbdef23
	 */
	public String getJobglbdef23Name() {
		if (!StrUtil.isNullOrEmpty(this.getJobglbdef23())) {
			String sql = " SELECT * FROM  UEC_POST T WHERE T.STATUS_CD = ? AND T.PK_POST = ? ";
			List<Object> params = new ArrayList<Object>();
			params.add(BaseUnitConstants.ENTT_STATE_ACTIVE);
			params.add(this.getJobglbdef23());
			List<UecPost> list = this.repository().jdbcFindList(sql, params, UecPost.class);
			if (list != null && list.size() > 0) {
				return list.get(0).getPostname();
			}
		}
		return "";
	}
	/**
	 * 三级基准岗位--jobglbdef24
	 */
	public String getJobglbdef24Name() {
		if (!StrUtil.isNullOrEmpty(this.getJobglbdef24())) {
			String sql = " SELECT * FROM  UEC_POST T WHERE T.STATUS_CD = ? AND T.PK_POST = ? ";
			List<Object> params = new ArrayList<Object>();
			params.add(BaseUnitConstants.ENTT_STATE_ACTIVE);
			params.add(this.getJobglbdef24());
			List<UecPost> list = this.repository().jdbcFindList(sql, params, UecPost.class);
			if (list != null && list.size() > 0) {
				return list.get(0).getPostname();
			}
		}
		return "";
	}
	/**
	 * 试用类型--trialType
	 */
	public String getTrialTypeName() {
		if (!StrUtil.isNullOrEmpty(this.getTrialType())) {
			String trialType = String.valueOf(this.getTrialType());
			if ("1".equals(trialType)) {
				return "转岗试用";
			} else if ("2".equals(trialType)) {
				return "入职试用";
			}
		}
		return "";
	}
	
	/**
	 * 异动业务--trnsevent
	 */
	public String getTrnseventName() {
		if (!StrUtil.isNullOrEmpty(this.getTrnsevent())) {
			String trnsevent = String.valueOf(this.getTrnsevent());
			if("1".equals(trnsevent)) {
				return "入职";
			}else if("2".equals(trnsevent)) {
				return "转正";
			}else if("3".equals(trnsevent)) {
				return "调配";
			}else if("4".equals(trnsevent)) {
				return "离职";
			}else if("5".equals(trnsevent)) {
				return "离职后变动";
			}
		}
		return "";
	}
	/**
	 * 是否在岗--poststat
	 */
	public String getPoststatName() {
		if (!StrUtil.isNullOrEmpty(this.getPoststat())) {
			if("Y".equals(this.getPoststat())) {
				return "是";
			}else if("N".equals(this.getPoststat())) {
				return "否";
			}
		}
		return "";
	}
	/**
	 * 是否结束--endflag
	 */
	public String getEndflagName() {
		if (!StrUtil.isNullOrEmpty(this.getEndflag())) {
			if("Y".equals(this.getEndflag())) {
				return "是";
			}else if("N".equals(this.getEndflag())) {
				return "否";
			}
		}
		return "";
	}
	/**
	 * 人员状态--jobglbdef1
	 */
	public String getJobglbdef1Name() {
		if (!StrUtil.isNullOrEmpty(this.getJobglbdef1())) {
			String sql = " SELECT * FROM  UEC_BD_DEFDOC T WHERE T.PK_DEFDOC = ? ";
			List<Object> params = new ArrayList<Object>();
			params.add(this.getJobglbdef1());
			List<UecBdDefdoc> list = this.repository().jdbcFindList(sql, params, UecBdDefdoc.class);
			if (list != null && list.size() > 0) {
				return list.get(0).getName();
			}
		}
		return "";
	}
}
